//
//  RedBagView.swift
//  LeGou
//
//  Created by lxm on 2022/10/8.
//

import UIKit
import Lottie
class RedBagView : LemonBaseView {

    //MARK: --------------------属性--------------------
    
    //MARK: --------------------UI控件--------------------
    let bg = ZMUtil.imageView(imageName: "bw_red")
    
    let label = ZMUtil.label(title: "周一 10:00-11:00 随机出现", color: .white, font: UIFont.systemFont(ofSize: 16, weight: .medium))
    //MARK: --------------------生命周期--------------------
    override init(frame: CGRect) {
        super.init(frame: frame)
        setUI()
        bindAction()
        addConstraints()
    }
    
    required init?(coder: NSCoder) {
        super.init(coder: coder)
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        setUI()
        bindAction()
        addConstraints()
    }

    //MARK: --------------------UI--------------------
    func setUI() {
        addSubview(bg)
        let starAnimationView = AnimationView(name: "homeOpen")
        starAnimationView.backgroundBehavior = .pauseAndRestore
        starAnimationView.play(toProgress: 1, loopMode: .loop) { ok in
        
        }
        addSubview(starAnimationView)
//        starAnimationView.backgroundColor = .red
        starAnimationView.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            
            let w : CGFloat = 48 * 2.5
            
            make.right.equalToSuperview().offset(-(24 + rpx(63) - (w / 2)))
            
            make.width.height.equalTo(w)
        }
        addSubview(label)
    }
    
    func addConstraints() {
        
        let w = SCREEN_W - 24

        let height = w / 352 * 93
        
        bg.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(12)
            make.right.equalToSuperview().offset(-12).priority(.high)
            make.top.bottom.equalToSuperview()
        }
        
        snp.makeConstraints { make in
//            make.width.equalTo(SCREEN_W)
            make.height.equalTo(height)
        }
        
        label.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(16 + 12)
            make.bottom.equalToSuperview().offset(-16)
        }
    }
    
    //MARK: --------------------methods--------------------
    func bindAction() {
        
    }
    //MARK: --------------------delegate--------------------

}
